import { User } from './data'

// 获取当月多少天，多少天周六日
export const getDay = () => {
  let date = new Date()
  let year = date.getFullYear()
  let month = date.getMonth()
  let allDay = new Date(year, month + 1, 0).getDate() //获取当月总天数
  let saturday = [] //周六
  let sunday = [] //周日
  for (let i = 1; i <= allDay; i++) {
    let week = new Date(year, month, i).getDay()
    let str = `${year}-${month + 1 < 10 ? '0' + (month + 1) : month + 1}-${
      i < 10 ? '0' + i : i
    }`
    if (week === 0) {
      sunday.push(str)
    } else if (week === 6) {
      saturday.push(str)
    }
  }
  return {
    allDay, // 当月
    sunday, // 周六
    saturday, // 周末
    days: allDay - (sunday.length + saturday.length), // 实际上班数
    vacation: sunday.length + saturday.length // 当月假期
  }
}

// 税前整体数据，days为0则代表双休，否则把固定假期写上，自动判断当月多少天工作天数，税后计算需要根据当地进行计算后续完善。
export const list: User[] = [
  {
    name: '白圣帝',
    days: 6, // 代表一月6天假期
    startDate: 9,
    endDate: 18.5,
    break: 1.5,
    sum: 6500,
    // 以下无需填写
    time: 0,
    allTime: 0,
    hour: 0,
    sun: 0,
    comfort: 0
  },
  {
    name: '黄某',
    days: 6, // 代表一月6天假期
    startDate: 9,
    endDate: 18,
    break: 1.5,
    sum: 9000,
    // 以下无需填写
    time: 0,
    allTime: 0,
    hour: 0,
    sun: 0,
    comfort: 0
  },
  {
    name: '张某',
    days: 0,
    startDate: 9,
    endDate: 18,
    break: 1.5,
    sum: 10000,
    // 以下无需填写
    time: 0,
    allTime: 0,
    hour: 0,
    sun: 0,
    comfort: 0
  },
  {
    name: '官某',
    days: 0,
    startDate: 9,
    endDate: 17.5,
    break: 1.5,
    sum: 8000,
    // 以下无需填写
    time: 0,
    allTime: 0,
    hour: 0,
    sun: 0,
    comfort: 0
  },
  {
    name: '翁天弟',
    days: 0,
    startDate: 0,
    endDate: 0,
    break: 0,
    sum: 19999,
    // 以下无需填写
    time: 0,
    allTime: 0,
    hour: 0,
    sun: 0,
    comfort: 0
  },
  {
    name: '郑某',
    days: 0,
    startDate: 8.5,
    endDate: [17.5, 17],
    break: 1.5,
    sum: 6500,
    // 以下无需填写
    time: 0,
    allTime: 0,
    hour: 0,
    sun: 0,
    comfort: 0
  },
  {
    name: '曾某',
    days: 4,
    startDate: 2,
    endDate: 14,
    break: 1.5,
    sum: 5500,
    // 以下无需填写
    time: 0,
    allTime: 0,
    hour: 0,
    sun: 0,
    comfort: 0
  },
  {
    name: '刘某',
    days: 4,
    startDate: 9,
    endDate: 18.5,
    break: 1.5,
    sum: 6500,
    // 以下无需填写
    time: 0,
    allTime: 0,
    hour: 0,
    sun: 0,
    comfort: 0
  },
  {
    name: '洪某',
    days: 0,
    startDate: 9,
    endDate: 18,
    break: 1.5,
    sum: 5500,
    // 以下无需填写
    time: 0,
    allTime: 0,
    hour: 0,
    sun: 0,
    comfort: 0
  },
  {
    name: '欧阳某',
    days: -1,
    startDate: 0,
    endDate: 0,
    break: 0,
    sum: 0,
    // 以下无需填写
    time: 0,
    allTime: 0,
    hour: 0,
    sun: 0,
    comfort: 0
  }
]

list.forEach((v) => {
  // 判断
  if (v.days == 0) {
    // v.days = 等于当月天数
    v.days = getDay().days
  } else {
    // v.days = 当月 - 月休天数
    v.days = getDay().allDay - v.days
  }
})
